package com.tinysand.advert.client;

import com.tinysand.advert.client.hystrix.SponsorHystrix;
import com.tinysand.advert.exception.AdvertException;
import com.tinysand.advert.support.AdPlan;
import com.tinysand.advert.support.AdPlanGetRequest;
import com.tinysand.advert.support.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 广告投放系统的微服务（Feign）调用客户端
 *
 * Created By TINY
 * Create Time 2020/2/27
 **/
@FeignClient(value = "eureka-client-advert-sponsor",
        fallback = SponsorHystrix.class)
@Component
public interface SponsorClient {

    /**
     * 根据请求参数获取对应的推广计划数据
     *
     * @param request 请求参数包装对象 {@link AdPlanGetRequest}
     * @return 推广计划数据
     * @throws AdvertException 业务异常
     */
    @PostMapping("/ad-sponsor/plan/get")
    CommonResponse<List<AdPlan>> getAdPlanByIds(
            @RequestBody AdPlanGetRequest request) throws AdvertException;

}
